import { defineConfig } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
import path from 'path';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
// https://vitejs.dev/config/
export default defineConfig({
	plugins: [
		uni(),
		createSvgIconsPlugin({
			// 指定需要缓存的图标文件夹
			iconDirs: [path.resolve(process.cwd(), 'src/static/svg')],
			// 指定symbolId格式
			symbolId: 'icon-[dir]-[name]'
		}),
		AutoImport({
			resolvers: [ElementPlusResolver()]
		}),
		Components({
			resolvers: [ElementPlusResolver()]
		})
	],
	server: {
	  proxy: {
	    '/api': {
	      target: 'http://192.168.1.101:8000',
	      changeOrigin: true,
	      rewrite: path => path.replace(/^\/api/, '')
	    }
	  },
	  hmr: {
	    overlay: false
	  },
	  host: '0.0.0.0'
	},
});
